Socket
Socket
Sign inDemoInstall

csv-parse

Package Overview
Dependencies
0
Maintainers
1
Versions
141
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    csv-parse

CSV parsing implementing the Node.js `stream.Transform` API


Version published
Weekly downloads
4.8M
increased by3.96%
Maintainers
1
Install size
654 kB
Created
Weekly downloads
 

Package description

What is csv-parse?

The csv-parse package is a flexible Node.js library that provides a parser converting CSV text input into arrays or objects. It implements the Node.js stream.Transform API. It is also capable of converting large datasets and supports many advanced features such as streaming and asynchronous processing.

What are csv-parse's main functionalities?

Parsing CSV to Arrays

This feature allows you to parse CSV data into arrays. Each row in the CSV data becomes an array.

const parse = require('csv-parse');
const assert = require('assert');
const input = 'a,b,c\nd,e,f';
parse(input, function(err, output){
  assert.deepEqual(output, [['a', 'b', 'c'], ['d', 'e', 'f']]);
});

Parsing CSV with Column Mapping

This feature allows you to map CSV columns to object properties, so each row in the CSV data becomes an object with named properties.

const parse = require('csv-parse');
const assert = require('assert');
const input = 'a,b,c\nd,e,f';
const parser = parse({columns: true}, function(err, records){
  assert.deepEqual(records, [{a: 'd', b: 'e', c: 'f'}]);
});
parser.write(input);
parser.end();

Asynchronous Iteration

This feature allows for asynchronous iteration over the parsed records, which is useful for handling large CSV files or streams.

const parse = require('csv-parse');
const fs = require('fs');
const parser = fs.createReadStream('/path/to/csv-file.csv').pipe(parse({columns: true}));
(async () => {
  for await (const record of parser) {
    // Work with each record
  }
})();

Other packages similar to csv-parse

Readme

Source

CSV Parser for Node.js

Build Status NPM NPM

Part of the CSV module, this project is a parser converting CSV text input into arrays or objects. It implements the Node.js stream.Transform API. It also provides a simple callback-based API for convenience. It is both extremely easy to use and powerful. It was first released in 2010 and is used against big data sets by a large community.

Documentation

Features

  • Follow the Node.js streaming API
  • Simplicity with the optional callback API
  • Support delimiters, quotes, escape characters and comments
  • Line breaks discovery
  • Support big datasets
  • Complete test coverage and samples for inspiration
  • No external dependencies
  • Work nicely with the csv-generate, stream-transform and csv-stringify packages
  • MIT License

Keywords

FAQs

Last updated on 03 Sep 2021

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc